While Loop in C

Introduction

The while loop in C language is used to execute a block of code several times until the given condition is true. The while loop is mainly used to perform repetitive tasks.

Unlike the for loop, it doesn't contain any initialization and update statements.

Syntax

while (condition) {
    statement(s);
}
            

Flowchart

Flowchart representation of the while loop goes here (image or diagram).

Example